import os.path
#Rene Ochoa Dorado

#dictionary with the file names
#comment and un-comment the files you want
#the more files you add the more host will get blocked by your firewall
#you will notice many web pages won't render because their hosts ip address
# is blocked


files = {}
#files['1'] = 'bt_level1';
#files['2'] = 'bt_level2.gz';
#files['3'] = 'bt_level3.gz';
files['4'] = 'tbg_primarythreats.gz';
files['5'] = 'Zo+tzMP_.txt.part.txt';
files['6'] = 'FrHTtImJ.txt.part.txt';
files['7'] = 'bt_bogon';
#open file for writting erease if file exists
fw = open( 'full_list.txt', 'w' )
#counter for the rows
count = 0

for k, v in files.iteritems():
	f = open( 'C:\Python25\combine_files\\'+files[k] , 'r' )
	for fline in f:
                #look for expected format
		if fline.find(':') > 0 and len(fline)>0:
                        #strip spaces and newlines from start and end of row
			fline = fline.rstrip()
			# sample row from a host file
			#Bogon:0.0.0.1-0.255.255.255
			spli = fline.split( ':' )
			if len( spli ) > 0:
                                #create row
				writefile = ''
				#row number
				writefile += str(count)
				#ip range #description
				writefile += ","+spli[1]+"#"+spli[0]+"\n"
				#write row
				fw.write( writefile )
				count += 1
